/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, {Component} from 'react';
import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
  TouchableOpacity,
  Image,
} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

import CodePushView from '../components/CodePushView'

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      syncMessage: '',
      progress: false,
    };
  }
  componentDidMount() {

    this.refCodePushView.startWithDialog()
    
  
  }
  onButtonPress() {
    
    this.refCodePushView.start()
  }

  render() {
    let {progress, syncMessage} = this.state

    return (
      <>
        <StatusBar barStyle="dark-content" />
        <SafeAreaView>
          <ScrollView
            contentInsetAdjustmentBehavior="automatic"
            style={styles.scrollView}>
            {global.HermesInternal == null ? null : (
              <View style={styles.engine}>
                <Text style={styles.footer}>Engine: Hermes</Text>
              </View>
            )}

            <View style={styles.body}>
              <View style={styles.sectionContainer}>
                <Text style={[styles.sectionTitle, {color: 'red'}]}>
                  这是第1.5.6个版本
                </Text>
                <Text>添加事件追踪</Text>
                <TouchableOpacity onPress={() => this.onButtonPress()}>
                  <Text style={[styles.sectionTitle, {color: 'red'}]}>
                    检查更新
                  </Text>
                </TouchableOpacity>

                <CodePushView 
                  getInstance={(childCp) => { this.refCodePushView = childCp }} 
                />

                <Image
                  source={require('../assets/img/1.png')}
                  style={{width: 50, height: 50}}
                />
                <Image
                  source={require('../assets/img/2.png')}
                  style={{width: 50, height: 50}}
                />
                <Image
                  source={require('../assets/img/pika.gif')}
                  // style={{width: 350, height: 350}}
                />
                <Image
                  source={require('../assets/img/591517.jpg')}
                  style={{width: 192, height: 108}}
                />
                <Image
                  source={require('../assets/img/591566.jpg')}
                  style={{width: 192, height: 108}}
                />
                <Text style={styles.sectionTitle}>Step One</Text>
                <Text style={styles.sectionDescription}>
                  Edit <Text style={styles.highlight}>App.js</Text> to change
                  this screen and then come back to see your edits.
                </Text>
              </View>
              <View style={styles.sectionContainer}>
                <Text style={styles.sectionTitle}>See Your Changes</Text>
                <Text style={styles.sectionDescription}>
                  <ReloadInstructions />
                </Text>
              </View>
              <View style={styles.sectionContainer}>
                <Text style={styles.sectionTitle}>Debug</Text>
                <Text style={styles.sectionDescription}>
                  <DebugInstructions />
                </Text>
              </View>
              <View style={styles.sectionContainer}>
                <Text style={styles.sectionTitle}>Learn More</Text>
                <Text style={styles.sectionDescription}>
                  Read the docs to discover what to do next:
                </Text>
              </View>
              <LearnMoreLinks />
            </View>
          </ScrollView>
        </SafeAreaView>

        
      </>
    );
  }
}

const styles = StyleSheet.create({
  scrollView: {
    backgroundColor: Colors.lighter,
  },
  engine: {
    position: 'absolute',
    right: 0,
  },
  body: {
    backgroundColor: Colors.white,
  },
  sectionContainer: {
    marginTop: 32,
    paddingHorizontal: 24,
  },
  sectionTitle: {
    fontSize: 24,
    fontWeight: '600',
    color: Colors.black,
  },
  sectionDescription: {
    marginTop: 8,
    fontSize: 18,
    fontWeight: '400',
    color: Colors.dark,
  },
  highlight: {
    fontWeight: '700',
  },
  footer: {
    color: Colors.dark,
    fontSize: 12,
    fontWeight: '600',
    padding: 4,
    paddingRight: 12,
    textAlign: 'right',
  },
});

export default App;
